<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <th:block th:include="include :: header('新增')"/>
  <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
  <form class="form-horizontal m" id="form-${tableName}-add">
<#list  columns as field>
      <#if field_index %2==0>
    <div class="row form-group">
      </#if>

<label class="col-sm-2 control-label">${field.columnComment!}：</label>
<div class="col-sm-4">
  <#if field.javaType=="Date">
    <input id="${field.columnName!}" name="${field.columnName!}" class="form-control" placeholder="yyyy-MM-dd"
           type="text">
      <#else >
    <input id="${field.columnName!}" name="${field.columnName!}" class="form-control" type="text">
  </#if>
</div>

    <#if field_index %2!=0 || !field_has_next >
      </div>
    </#if>
</#list>
  </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
  var prefix = ctx + "${tableName}";
  $("#form-${tableName}-add").validate({
    onkeyup: false,
    rules: {
      isValid: {maxlength: 1},
      createdBy: {maxlength: 32},
      createdTime: {date: true},
      updatedBy: {maxlength: 32},
      updatedTime: {date: true},
    },
    focusCleanup: true
  });

  function submitHandler() {
    if ($.validate.form()) {
      $.operate.save(prefix + "/add", $('#form-${tableName}-add').serialize());
    }
  }

<#list  columns as field>
<#if field.javaType=="Date">
  $("input[name='${field.columnName}']").datetimepicker({
    format: "yyyy-mm-dd",
    minView: "month",
    autoclose: true
  });
</#if>
</#list>
</script>
</body>
</html>